Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode: fix possible NULL dereference #189

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

DavidKorczynski
Copy link
Contributor

Found by a recently added fuzzer.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61743

Found by a recently added fuzzer.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61743

Signed-off-by: David Korczynski <[email protected]>
Copy link
Contributor

@leonardo-albertovich leonardo-albertovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this is caused by unpack_meta_type not being called (ie. the msgpack buffer not having a type map key) so instead of handling each case on their own (1009, 999, 983 and other types that don't go through that conditional but need the actual metric to be created) we might want to ensure that decode_context->map and decode_context->map->parent are not NULL in line 980 as a pre-requisite for the remainder of the function.

Could you please do that?

@DavidKorczynski
Copy link
Contributor Author

Could you please do that?

yep

Copy link
Contributor

@leonardo-albertovich leonardo-albertovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: Sorry, my connection was spotty and I sent the previous message twice.

Signed-off-by: David Korczynski <[email protected]>
@DavidKorczynski
Copy link
Contributor Author

Adjusted the fix @leonardo-albertovich

@DavidKorczynski
Copy link
Contributor Author

@edsiper could you please take a look?

@@ -978,6 +978,9 @@ static int unpack_basic_type_meta(mpack_reader_t *reader, size_t index, void *co

if (CMT_DECODE_MSGPACK_SUCCESS == result) {
decode_context->map->label_count = cfl_list_size(&decode_context->map->label_keys);
if (decode_context->map == NULL || decode_context->map->parent == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a chance that decode_context->map is NULL ideally we want do it before the previous line otherwise it leads to a corruption decode_context->map->...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: David Korczynski <[email protected]>
@edsiper edsiper merged commit d0b9aee into fluent:master Oct 19, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants